function print_alert(content) {
    navigator.notification.alert(content, alertDismissed, 'Wedding Helper', 'Done');
}
function print_alert_network() {
    navigator.notification.alert("Please check your internet connection", alertDismissed, 'Connection failed', 'Done');
}
function alertDismissed() {

}
function print_confirm(content, function_callback) {
    navigator.notification.confirm(
            content,
            function_callback, // callback to invoke with index of button pressed
            'Wedding Helper', // title
            'OK,Cancel'          // buttonLabels
            );
}
function wd_redirect(url) {
    window.location = url;
}
var online = true;
function check_connect_internet() {
}

function checkNetwork() {
    if(checkConnection()===false){
        print_alert_network();
    }
}

function checkConnection() {
    var networkState = navigator.connection.type;

    var states = {};
    states[Connection.UNKNOWN] = 'Unknown connection';
    states[Connection.ETHERNET] = 'Ethernet connection';
    states[Connection.WIFI] = 'WiFi connection';
    states[Connection.CELL_2G] = 'Cell 2G connection';
    states[Connection.CELL_3G] = 'Cell 3G connection';
    states[Connection.CELL_4G] = 'Cell 4G connection';
    states[Connection.CELL] = 'Cell generic connection';
    states[Connection.NONE] = 'No network connection';
    if (networkState == Connection.NONE || networkState == Connection.UNKNOWN) {
        return false;
    }else{
        return true;
    }

}
$(function() {
    document.addEventListener("deviceready", checkNetwork, false);
    $.get(localStorage.domain_app+"/webservice/getAdvertisement.php",function(res) {
        
            if(res.error==0){
                $("#bannerRotator").html(res.html);
                bannerRotator('#bannerRotator', 500, 8000);
            }

        }, "json");
     //redirect by js
     $(".link_home").click(function(){
        wd_redirect('home.html');
    });
     $(".link_setting").click(function(){
        wd_redirect('setting.html');
    });
    $(".link_event").click(function(){
        wd_redirect('event.html');
    });
    $(".link_guest").click(function(){
        wd_redirect('guestList.html');
    });
    $(".link_todo").click(function(){
        wd_redirect('toDoList.html');
    });
    $(".link_budget").click(function(){
        wd_redirect('budget.html');
    });
    $(".link_invite").click(function(){
        wd_redirect('selectEvent.html');
    });
    $(".link_appinfo").click(function(){
        wd_redirect('appInfo.html');
    });
    $(".link_profile_term_of_use").click(function(){
        wd_redirect('termOfUse.html');
    });
    
});


